package com.hksj.cm.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hksj.cm.dto.DeviceLevelSettingDTO;
import com.hksj.cm.service.DeviceLevelService;
import com.hksj.cm.vo.ConstructionStandardsVO;
import com.hksj.cm.vo.DeviceLevelVO;
import com.hksj.common.core.model.Rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName DeviceLevelController
 * @Description TODO
 * @Author @陈章
 * @Date 2024/7/22 10:33
 * @Version 1.0
 */
@Api(tags = "设备评级")
@RestController
@RequestMapping("/api/deviceLevel")
public class DeviceLevelController {
    @Autowired
    private DeviceLevelService service;


    @ApiOperation(value = "建造标准及统计列表查询")
    @GetMapping("/selectConstructionStandardsList")
    public Rest<List<ConstructionStandardsVO>> selectConstructionStandardsList() {
        return Rest.ok(service.selectConstructionStandardsList());
    }


    @ApiOperation(value = "根据建造标准查询未绑定设备的评级列表")
    @GetMapping("/queryUnboundDeviceList")
    public Rest<Page<DeviceLevelVO>> queryUnboundDeviceList(@ApiParam(value = "起始页", required = false, defaultValue = "1") @RequestParam(required = false, defaultValue = "1") Integer pageNum,
                                                            @ApiParam(value = "每页大小", required = false, defaultValue = "10") @RequestParam(required = false, defaultValue = "15") Integer pageSize,
                                                            @ApiParam(value = "设备名称", required = false) @RequestParam(required = false) String deviceName,
                                                            @ApiParam(value = "建造标准id", required = false) @RequestParam(required = false) String constructionStandardsValue) {
        Page<DeviceLevelVO> page = service.queryUnboundDeviceList(pageSize, pageNum, deviceName, constructionStandardsValue);
        return Rest.ok(page);

    }

    @ApiOperation(value = "根据建造标准查询已绑定设备的评级列表")
    @GetMapping("/queryAlreadyBoundDeviceList")
    public Rest<Page<DeviceLevelVO>> queryAlreadyBoundDeviceList(@ApiParam(value = "起始页", required = false, defaultValue = "1") @RequestParam(required = false, defaultValue = "1") Integer pageNum,
                                                                 @ApiParam(value = "每页大小", required = false, defaultValue = "10") @RequestParam(required = false, defaultValue = "15") Integer pageSize,
                                                                 @ApiParam(value = "建造标准id", required = false) @RequestParam(required = false) String constructionStandardsValue) {
        Page<DeviceLevelVO> page = service.queryAlreadyBoundDeviceList(pageSize, pageNum, constructionStandardsValue);
        return Rest.ok(page);

    }

    @ApiOperation(value = "新增或更新设备评级设置")
    @PostMapping("/createDeviceLevelSetting")
    public Rest<String> createDeviceLevelSetting(@RequestBody List<DeviceLevelSettingDTO> list) {
        return service.createDeviceLevelSetting(list);
    }

    @ApiOperation(value = "删除设备评级设置")
    @GetMapping("/delDeviceLevelSetting")
    public Rest<String> delDeviceLevelSetting(Long id) {
        return service.delDeviceLevelSetting(id);
    }
}
